﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using App1AppHandler;

namespace Reborn_Server.App1AppHandler
{
    public class Spell_RejunivateMagic : Buff
    {
        private int RegenAdded = 5;

        public Spell_RejunivateMagic() 
        {
        }

        override public void Resume(CreatureBase targetCreatureBase, SpellIcon _spellIcon, int timeRemaining, int castLevel, int castCharacterID, int castInt, int castWis, int optionalValue, string xmlData)
        {
            if (_spellIcon.Name.IndexOf("Rank 2") > -1)
                RegenAdded = 3 + castLevel;
            else
                RegenAdded = 3 + (castLevel / 2);

            minutesLeft = timeRemaining;
            base.Resume(targetCreatureBase, _spellIcon, timeRemaining, castLevel, castCharacterID, castInt, castWis, optionalValue, xmlData);

            if (spellIcon.Skill == "Mentality")
                TargetCreatureBase.ManaRegen = TargetCreatureBase.ManaRegen + RegenAdded;
            else if (spellIcon.Skill == "Might")
                TargetCreatureBase.StaminaRegen = TargetCreatureBase.StaminaRegen + RegenAdded;
            else if (spellIcon.Skill == "Resilience")
                TargetCreatureBase.HPRegen = TargetCreatureBase.HPRegen + RegenAdded;

            spellTimer.Start();
        }
        public void Cast(CreatureBase myCreatureBase, int CastLevel, long CreatureGUID)
        {
            List<MapItem> MapItemsWithin12;
            if (base.InitializeCast(myCreatureBase, CastLevel, CreatureGUID, true, out MapItemsWithin12) == false)
                return;

            if (spellIcon.Name.IndexOf("Rank 2") > -1)
                RegenAdded = 3 + CastLevel;
            else
                RegenAdded = 3 + (CastLevel / 2);

            minutesLeft = System.Convert.ToInt32(Math.Floor(CastingCreatureWis / 2.00));

            if (spellIcon.Skill == "Mentality")
                TargetCreatureBase.ManaRegen = TargetCreatureBase.ManaRegen + RegenAdded;
            else if (spellIcon.Skill == "Might")
                TargetCreatureBase.StaminaRegen = TargetCreatureBase.StaminaRegen + RegenAdded;
            else if (spellIcon.Skill == "Resilience")
                TargetCreatureBase.HPRegen = TargetCreatureBase.HPRegen + RegenAdded;

            TargetCreatureBase.buffManager.UpdateBuffs();

            spellTimer.Start();
        }
        public override void RemoveSpell(bool updateBuffs, bool sendMessage)
        {
            base.RemoveSpell(updateBuffs, sendMessage);

            if (spellIcon.Skill == "Mentality")
                TargetCreatureBase.ManaRegen = TargetCreatureBase.ManaRegen - RegenAdded;
            else if (spellIcon.Skill == "Might")
                TargetCreatureBase.StaminaRegen = TargetCreatureBase.StaminaRegen - RegenAdded;
            else if (spellIcon.Skill == "Resilience")
                TargetCreatureBase.HPRegen = TargetCreatureBase.HPRegen - RegenAdded;
        }
    }
}
